package 寒假刷题;

public class 最优除法 {
    public String optimalDivision(int[] nums) {
        StringBuilder builder = new StringBuilder();
        int n = nums.length;
        if (n==1)
            return nums[0]+"";
        if (n==2)
            return nums[0]+"/"+nums[1];
        for (int i = 0; i < n; i++) {
            if (i==0){
                builder.append(nums[0]).append("/(");
            }
            else if (i==n-1){
                builder.append(nums[i]).append(")");
            }
            else
                builder.append(nums[i]).append("/");
        }
        return builder.toString();
    }
}
